import Router from 'koa-router';
import KoaRouter from 'koa-router'
import KoaBootRoutes from '@framework/web/KoaBootRoutes';

/**
 * 路由封装
 */
class KoaBootRouter {

    /**
     * koa路由源对象
     */
    private router: Router = new KoaRouter();

    /**
     * 前缀
     */
    private prefix: string;

    /**
     * 路由规则
     */
    private routers: Array<KoaBootRoutes> = new Array();
    
    /**
     * 路由规则
     * @returns 路由规则
     */
    public getRouters(): Array<KoaBootRoutes> {
        return this.routers;
    }
    
    /**
     * 路由规则
     * @returns 路由规则
     */
    public setRouters(routers: Array<KoaBootRoutes>): void {
        this.routers = routers;
    }
    
    /**
     * 路由规则
     * @returns 路由规则
     */
    public addRoutes(koaRouters: KoaBootRoutes): void {
        this.routers.push(koaRouters);
    }
    
    /**
     * Koa路由
     * @returns Koa路由
     */
    public getRouter(): Router {
        return this.router;
    }


    /**
     * 获取前缀
     * @returns 前缀
     */
    public getPrefix(): string {
        return this.prefix;
    }

    /**
     * 设置前缀
     * @param prefix 前缀
     */
    public setPrefix(prefix: string): void {
        this.prefix = prefix;
    }

}

export default KoaBootRouter;